import { Component, Input } from '@angular/core';
import { KnowledgeCenterService } from '../knowledge-center.service';
import { InsightModel } from '../models/insight.model';
import { LrtmService, LongRunningTaskTypeEnum } from '../../../framework/lrtm/lrtm.service';
import { AppComponent } from '../../../app.component';
import { UtilsService } from '../../../shared/services/utils.service';

@Component({
    selector: 'app-news-list',
    templateUrl: './news-list.component.html',
    providers: [KnowledgeCenterService, LrtmService]
})
export class NewsListComponent {

    @Input() insights: InsightModel[];

    constructor(
        private rootComponent: AppComponent,
        private kcService: KnowledgeCenterService,
        private lrtmService: LrtmService
    ) { }

    downloadReport( insight: InsightModel ): void {
        this.lrtmService
            .runTask(this.rootComponent, insight.fileName + "_" + UtilsService.getReportDate(), LongRunningTaskTypeEnum.InsightsPDF, {
                fileId: insight.fileS3Name,
                fileName: insight.fileName
            }, true)
            .subscribe(report => {});
    }
}
